package cp3120.ucm.client;

import cp3120.ucm.*;
import cp3120.dao.DAOFactory;
import cp3120.model.User;
import cp3120.view.MainUI;

/**
 * Author: Adam Scarr
 * Date: 26/03/2009
 * Time: 9:41:03 AM
 * PRECONDITION: A request to update a user from the register Ui has been made<br>
 * POST-CONDITION: The system updates and displays the main UI <br>
 * 1. System gets the new user details from the registration UI<br>
 * 2. System updates the new suer details to the database<br>
 * 3. Syetem removes the userregistration<br>
 */
public class UCUpdateUser implements UCController {
    /**
     * runs this UC
     */
    public void run() {
        User user = new User();
        MainUI.getInstance().getRegistrationUI().insertInto(user);

        DAOFactory.getUserDAO().updateUser(user);
        MainUI.getInstance().getRegistrationUI().setVisible(false);
        MainUI.getInstance().getRegistrationUI().setError(null);
    }
}
